﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;

namespace NK.Domain.Entities
{
    public class ProductInfo
    {
        [Key()]
        public int ID { get; set; }

        public string Group { get; set; }

        public string GroupCode { get; set; }

        //[MaxLength(20)]
        [DisplayFormat(DataFormatString = "{0:s}")]
        public string BarCode { get; set; }

        public string SpecialBarCode { get; set; }

        public string POSDescription { get; set; }

        public string ProductName { get; set; }

        public string PKT { get; set; }

        public string Package { get; set; }

        [DisplayFormat(DataFormatString = "{0:#,###}")]
        public double Cost { get; set; }

        [DisplayFormat(DataFormatString = "{0:#%}")]
        public double VAT { get; set; }

        [Display(Name = "Cost&VAT", Description = "Cost include VAT")]
        [DisplayFormat(DataFormatString = "{0:#,###}")]
        public double CostIncludeVAT { get; set; }

        [DisplayFormat(DataFormatString = "{0:#,###}")]
        public double PriceA { get; set; }

        [DisplayFormat(DataFormatString = "{0:#,###}")]
        public double PriceB { get; set; }

        [DisplayFormat(DataFormatString = "{0:#,###}")]
        public double PriceC { get; set; }

        [DisplayFormat(DataFormatString = "{0:#,###}")]
        public double PriceD { get; set; }

        public bool IsDeleted { get; set; }

        public void UpdateValues(ProductInfo newValues)
        {
            Group = newValues.Group;
            GroupCode = newValues.GroupCode;
            SpecialBarCode = newValues.SpecialBarCode;
            Package = newValues.Package;
            POSDescription = newValues.POSDescription;
            ProductName = newValues.ProductName;
            PKT = newValues.PKT;
            Cost = newValues.Cost;
            VAT = newValues.VAT;
            CostIncludeVAT = newValues.CostIncludeVAT;
            PriceA = newValues.PriceA;
            PriceB = newValues.PriceB;
            PriceC = newValues.PriceC;
            PriceD = newValues.PriceD;
        }

        public Dictionary<string, string> ToDictionary()
        {
            var result = new Dictionary<string, string>();
            result.Add("ID", ID.ToString());
            result.Add("Group", Group);
            result.Add("GroupCode", GroupCode);
            result.Add("BarCode", BarCode);

            result.Add("SpecialBarCode", SpecialBarCode);
            result.Add("POSDescription", POSDescription);
            result.Add("ProductName", ProductName);
            result.Add("PKT", PKT);

            result.Add("Package", Package);
            result.Add("Cost", Cost.ToString());
            result.Add("VAT", VAT.ToString());
            result.Add("CostIncludeVAT", CostIncludeVAT.ToString());

            result.Add("PriceA", PriceA.ToString());
            result.Add("PriceB", PriceB.ToString());
            result.Add("PriceC", PriceC.ToString());
            result.Add("PriceD", PriceD.ToString());

            return result;
        }
    }
}
